home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / osi / isode / vmsisode / vmsisode80_tar.Z / vmsisode80_tar / sockit / gccinclude / sys / file.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-24  |  7.4 KB  |  224 lines

  1. /* @(#)file.h    1.12 (ULTRIX) 6/10/86 */
  2.  
  3. /************************************************************************
  4.  *                                    *
  5.  *            Copyright (c) 1985, 1986 by            *
  6.  *        Digital Equipment Corporation, Maynard, MA        *
  7.  *            All rights reserved.                *
  8.  *                                    *
  9.  *   This software is furnished under a license and may be used and    *
  10.  *   copied  only  in accordance with the terms of such license and    *
  11.  *   with the  inclusion  of  the  above  copyright  notice.   This    *
  12.  *   software  or  any  other copies thereof may not be provided or    *
  13.  *   otherwise made available to any other person.  No title to and    *
  14.  *   ownership of the software is hereby transferred.            *
  15.  *                                    *
  16.  *   This software is  derived  from  software  received  from  the    *
  17.  *   University    of   California,   Berkeley,   and   from   Bell    *
  18.  *   Laboratories.  Use, duplication, or disclosure is  subject  to    *
  19.  *   restrictions  under  license  agreements  with  University  of    *
  20.  *   California and with AT&T.                        *
  21.  *                                    *
  22.  *   The information in this software is subject to change  without    *
  23.  *   notice  and should not be construed as a commitment by Digital    *
  24.  *   Equipment Corporation.                        *
  25.  *                                    *
  26.  *   Digital assumes no responsibility for the use  or  reliability    *
  27.  *   of its software on equipment which is not supplied by Digital.    *
  28.  *                                    *
  29.  ************************************************************************/
  30. /************************************************************************
  31.  *            Modification History                *
  32.  *                                    *
  33.  *    11-Mar-86    Larry Palmer                     *
  34.  *    Added flag to mark a file as being used by n-bufferring.
  35.  *                                    *
  36.  *    Stephen Reilly, 09-Sept-85                    *
  37.  *     Modified to handle the new lockf code.                *
  38.  *                                    *
  39.  *    Stephen Reilly, 09-Sept-85                    *
  40.  *     Modified to handle the new lockf code.                *
  41.  *
  42.  *    David L Ballenger, 28-Mar-1985                    *
  43.  * 0001    Modify so that <fcntl.h> can simply include this file.  This    *
  44.  *    file already contains all the definitions contained in        *
  45.  *    <fcntl.h>, plus all the definitions that would need to be added    *
  46.  *    to <fcntl.h> from the BRL version for System V emulation.  No    *
  47.  *    sense in defining things in multiple places.            *
  48.  *                                    *
  49.  *    Larry Cohen, 4-April-1985                    *
  50.  * 0002 Changes to support open block if in use capability        *
  51.  *    FBLKINUSE                            *
  52.  *    O_BLKINUSE - open blocks if IINUSE bit in inode is set        *
  53.  *                                    *
  54.  *    FBLKANDSET                            *
  55.  *    O_BLKANDSET - open blocks if IINUSE bit in inode is set        *
  56.  *            and sets after open succeeds.            *
  57.  *                                    *
  58.  *     Greg Depp 8-April-1985                        *
  59.  * 0003 Added DTYPE_PORT to define System V IPC Named Pipe type        *
  60.  *                                    *
  61.  *    Paul Shaughnessy, 24-December-1985                *
  62.  * 0004 Added syncronous write capability in open and fcntl system      *
  63.  *    calls.                                *
  64.  *                                    *
  65.  *    Tim Burke,    10-June-1986                    *
  66.  * 0005 Inserted FSYSV and O_SYSV which tells if the program is to    *
  67.  *    run as a System V program.  If so use a "RAW" type of default   *
  68.  *    settings rather that the normal "COOKED" style on terminal     *
  69.  *    line defaults.                            *
  70.  *                                    *
  71.  ************************************************************************/
  72.  
  73.  
  74. /* Don't define things twice.  This protects form a source file which
  75.  * includes both <fcntl.h> and <sys/file.h>
  76.  */
  77. #ifndef __FCNTL__
  78. #define __FCNTL__
  79.  
  80. #ifdef KERNEL
  81. /*
  82.  * Descriptor table entry.
  83.  * One for each kernel object.
  84.  */
  85. struct    file {
  86.     int    f_flag;        /* see below */
  87.     short    f_type;        /* descriptor type */
  88.     short    f_count;    /* reference count */
  89.     short    f_msgcount;    /* references from message queue */
  90.     struct    fileops {
  91. /*        return    function    arguments        */
  92.         int    (*fo_rw)(    /* fp,uio,rw        */ );
  93.         int    (*fo_ioctl)(    /* fp,com,data,cred    */ );
  94.         int    (*fo_select)(    /* fp,which        */ );
  95.         int    (*fo_close)(    /* fp            */ );
  96.     } *f_ops;
  97.     caddr_t    f_data;        /* inode */
  98.     off_t    f_offset;
  99.     struct ucred *f_cred;
  100. };
  101.  
  102. struct    file *file, *fileNFILE;
  103. int    nfile;
  104. struct    file *getf();
  105. struct    file *falloc();
  106. #endif
  107.  
  108. /*
  109.  * flags- also for fcntl call.
  110.  */
  111. #define    FOPEN        (-1)
  112. #define    FREAD        00001        /* descriptor read/receive'able */
  113. #define    FWRITE        00002        /* descriptor write/send'able */
  114. #define    FNDELAY        00004        /* no delay */
  115. #define    FAPPEND        00010        /* append on each write */
  116. #define    FMARK        00020        /* mark during gc() */
  117. #define    FDEFER        00040        /* defer for next gc pass */
  118. #define    FASYNC        00100        /* signal pgrp when data ready */
  119. #define    FSHLOCK        00200        /* shared lock present */
  120. #define    FEXLOCK        00400        /* exclusive lock present */
  121. #define FSYNCRON    0100000        /* Write file syncronously *0004*/
  122. #define FNBUF        0200000        /* file used for n-buffering */
  123. /* bits to save after open */
  124. #define    FMASK        0110113     /* 0004 */
  125. #define    FCNTLCANT    (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
  126.  
  127. /* open only modes */
  128. #define    FCREAT        01000        /* create if nonexistant */
  129. #define    FTRUNC        02000        /* truncate to zero length */
  130. #define    FEXCL        04000        /* error if already created */
  131. #define FBLKINUSE      010000        /* block if "in use"    *0002*/
  132. #define FBLKANDSET     (020000 | FBLKINUSE) /* block, test and set "in use" */    
  133. #define FSYSV        0200000        /* System V style program */
  134.  
  135. /* fcntl(2) requests
  136.  */
  137. #define    F_DUPFD    0    /* Duplicate fildes */
  138. #define    F_GETFD    1    /* Get fildes flags */
  139. #define    F_SETFD    2    /* Set fildes flags */
  140. #define    F_GETFL    3    /* Get file flags */
  141. #define    F_SETFL    4    /* Set file flags */
  142. #define    F_GETOWN 5    /* Get owner */
  143. #define F_SETOWN 6    /* Set owner */
  144. #define    F_GETLK    7    /* Get file lock */
  145. #define    F_SETLK    8    /* Set file lock */
  146. #define    F_SETLKW 9    /* Set file lock and wait */
  147. #define F_SETSYN 10    /* Set syncronous write *0004*/
  148. #define F_CLRSYN 11    /* Clear syncronous write *0004*/
  149.  
  150. /*
  151.  * User definitions.
  152.  */
  153.  
  154. /* file segment locking set data type - information passed to system by user */
  155. #ifndef    F_RDLCK
  156. struct flock {
  157.     short    l_type;
  158.     short    l_whence;
  159.     long    l_start;
  160.     long    l_len;        /* len = 0 means until end of file */
  161.     int    l_pid;
  162. };
  163. #endif
  164.  
  165. /*
  166.  * Open call.
  167.  */
  168. #define    O_RDONLY    000        /* open for reading */
  169. #define    O_WRONLY    001        /* open for writing */
  170. #define    O_RDWR        002        /* open for read & write */
  171. #define    O_NDELAY    FNDELAY        /* non-blocking open */
  172. #define    O_APPEND    FAPPEND        /* append on each write */
  173. #define    O_CREAT        FCREAT        /* open with file create */
  174. #define    O_TRUNC        FTRUNC        /* open with truncation */
  175. #define    O_EXCL        FEXCL        /* error on create if file exists */
  176. #define O_BLKINUSE      FBLKINUSE    /* block if "in use"    *0002*/
  177. #define O_BLKANDSET     FBLKANDSET    /* block, test and set "in use"    */
  178. #define O_FSYNC        FSYNCRON    /* syncronous write *0004*/
  179. #define O_SYNC        O_FSYNC        /* system V synchronous write */
  180. #define O_SYSV        FSYSV        /* system V style program */
  181. /*
  182.  * Flock call.
  183.  */
  184. #define    LOCK_SH        1    /* shared lock */
  185. #define    LOCK_EX        2    /* exclusive lock */
  186. #define    LOCK_NB        4    /* don't block when locking */
  187. #define    LOCK_UN        8    /* unlock */
  188.  
  189. /* 
  190.  *    file segment locking types
  191.  */
  192. #define    F_RDLCK    01    /* Read lock */
  193. #define    F_WRLCK    02    /* Write lock */
  194. #define    F_UNLCK    03    /* Remove lock(s) */
  195.  
  196. /*
  197.  * Access call.
  198.  */
  199. #define    F_OK        0    /* does file exist */
  200. #define    X_OK        1    /* is it executable by caller */
  201. #define    W_OK        2    /* writable by caller */
  202. #define    R_OK        4    /* readable by caller */
  203.  
  204. /*
  205.  * Lseek call.
  206.  */
  207. #define    L_SET        0    /* absolute offset */
  208. #define    L_INCR        1    /* relative to current offset */
  209. #define    L_XTND        2    /* relative to end of file */
  210.  
  211. #ifdef KERNEL
  212. #define    GETF(fp, fd) { \
  213.     if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
  214.         u.u_error = EBADF; \
  215.         return; \
  216.     } \
  217. }
  218. #define    DTYPE_INODE    1    /* file */
  219. #define    DTYPE_SOCKET    2    /* communications endpoint */
  220. #define    DTYPE_PORT    3    /* port (named pipe) 0003 */
  221. #endif KERNEL
  222.  
  223. #endif __FCNTL__
  224.